// unocss.rules.ts
import { transformPxToRpx } from "../src/utils/index";

export default [
  [
    /^w-(\d+)$/,
    ([, d]) => {
      return { width: transformPxToRpx(d) };
    },
  ],
  [
    /^h-(\d+)$/,
    ([, d]) => {
      return { height: transformPxToRpx(d) };
    },
  ],
  [
    /^lh-(\d+)$/i,
    ([, d]) => {
      return { "line-height": transformPxToRpx(d) };
    },
  ],
  [
    /^mt-(\d+)$/,
    ([, d]) => {
      return { "margin-top": transformPxToRpx(d) };
    },
  ],
  [
    /^mr-(\d+)$/,
    ([, d]) => {
      return { "margin-right": transformPxToRpx(d) };
    },
  ],
  [
    /^mb-(\d+)$/,
    ([, d]) => {
      return { "margin-bottom": transformPxToRpx(d) };
    },
  ],
  [
    /^ml-(\d+)$/,
    ([, d]) => {
      return { "margin-left": transformPxToRpx(d) };
    },
  ],
  [
    /^mx-(\d+)$/,
    ([, d]) => {
      const rpxValue = transformPxToRpx(d);
      return { "margin-left": rpxValue, "margin-right": rpxValue };
    },
  ],
  [
    /^my-(\d+)$/,
    ([, d]) => {
      const rpxValue = transformPxToRpx(d);
      return { "margin-top": rpxValue, "margin-bottom": rpxValue };
    },
  ],
  [
    /^pt-(\d+)$/,
    ([, d]) => {
      return { "padding-top": transformPxToRpx(d) };
    },
  ],
  [
    /^pr-(\d+)$/,
    ([, d]) => {
      return { "padding-right": transformPxToRpx(d) };
    },
  ],
  [
    /^pb-(\d+)$/,
    ([, d]) => {
      return { "padding-bottom": transformPxToRpx(d) };
    },
  ],
  [
    /^pl-(\d+)$/,
    ([, d]) => {
      return { "padding-left": transformPxToRpx(d) };
    },
  ],
  [
    /^px-(\d+)$/,
    ([, d]) => {
      const rpxValue = transformPxToRpx(d);
      return { "padding-left": rpxValue, "padding-right": rpxValue };
    },
  ],
  [
    /^py-(\d+)$/,
    ([, d]) => {
      const rpxValue = transformPxToRpx(d);
      return { "padding-top": rpxValue, "padding-bottom": rpxValue };
    },
  ],
];
